/**
 * create by young (young2f@outlook.com) on 2020/12/4
 */
'use strict';
const model = require('../base/tModelBase');
const _ = require('lodash');
module.exports = app => {
  const mongoose = app.mongoose;
  const schema = mongoose.Schema;
  const connect = app.mongooseDB.get('pmcBus');
  const json = {
    code: { type: String, _type: 'code', title: '编码', required: true },
    date: { type: Date, _type: 'date', title: '日期',  enableArea: [ 'table', ] },
    experimentName: { type: String, _type: 'string', title: '实验名称',enableArea: [ 'table', ] },
    experimentType: { type: String, _type: 'string', title: '实验类型',enableArea: [ 'table', ] },
    customer: { type: String, _type: 'string', title: '客户名称', enableArea: [ 'table', ], },
    salesman: { type: String, _type: 'string', title: '业务员', enableArea: [ 'table', ], },
    experimentMan: { type: String, _type: 'string', title: '实验人', enableArea: [ 'table', ], },
    memo: { type: String, _type: 'string', title: '备注', },
    customerDesc: { type: String, _type: 'string', title: '客户描述', enableArea: [ 'table', ], },
    experimentRequire: { type: String, _type: 'string', title: '实验要求及标准描述', enableArea: [], },
    experimentDesc: { type: String, _type: 'string', title: '实验过程描述', enableArea: [], },
    target: { type: String, _type: 'string', title: '实验目的或课题', enableArea: [], },
    conclusions: { type: Array, _type: 'array', title: '实验结论列表', enableArea: [], },
    conclusion: { type: String, _type: 'string', title: '实验结论', enableArea: [], },
    recordType: { type: String, _type: 'string', title: '记录类型', enableArea: [], default:"customer"},
    steps: { type: Array, _type: 'array', title: '实验记录', },
    fileList: { type: Array, _type: 'array', title: '污水系统参数调查表', },
  };
  const _model = _.cloneDeep(model);
  _.assign(_model, json);
  const _schema = new schema(
    _model,
    { timestamps: { createdAt: 'createdTs', updatedAt: 'updatedTs' } }
  );
  return connect.model('ExperimentRecord', _schema);
};
